//
//  DiscoverViewController.swift
//  weibo
//
//  Created by 陈勇 on 16/2/22.
//  Copyright © 2016年 chenyong. All rights reserved.
//

import UIKit

//cell 的重用的标示符号
private let CZDiscoverCellID = "CZDiscoverCellID"

class DiscoverViewController: RootViewController {

    override func viewDidLoad() {

        // 设置刷新控件
        setupRefreshControl()
        
        super.viewDidLoad()
        // 注册可重用 cell
        tableView?.registerClass(UITableViewCell.self, forCellReuseIdentifier: CZDiscoverCellID)
        
        visitorView?.setupInfo("visitorView_image_message", message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")

        

    }

    override func loadData() {
        //开始刷新
        refreshControl?.beginRefreshing()
        
        let when = dispatch_time(DISPATCH_TIME_NOW, Int64(Double(NSEC_PER_MSEC) * 1.0))
        
        dispatch_async(dispatch_get_main_queue()) { () -> Void in
            
            self.dataCount += 10
            //结束刷新
            self.refreshControl?.endRefreshing()
            
            self.tableView?.reloadData()
        }
        
    }
    
    //私有属性
    private var dataCount = 0
}

extension DiscoverViewController{
    
    
    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        return dataCount
        
    }
   ///数据源方法
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        
        let cell = tableView.dequeueReusableCellWithIdentifier(CZDiscoverCellID, forIndexPath: indexPath)
        
        cell.textLabel?.text = "\(indexPath.row)"
        
        return cell
    }
    
    }
    
    
    

